package com.ruoyi.biz.model.req;

import com.ruoyi.common.core.domain.CoreEntity;
import lombok.Data;

import java.util.*;

@Data
public class BizProjectReq extends CoreEntity {
    private String projectName;
    private Long sectorId;
    private String classifyCode;
    private Date signTimeStart;
    private Date signTimeEnd;
    private String principalName;
    private String trusteeName;
    private String channelName;
    private String projectStatus;
    private String transactorName;
    private String userName;
    private String deptId;
    private String enforceDeptId;

    private Boolean createTimeSort;
    private Boolean prioritySort;
    private Boolean deadlineSort;
    private Boolean totalAmountSort;
    private Boolean realAmountSort;
    private Date receiptTimeStart;
    private Date receiptTimeEnd;
    private boolean sorted;
    private String sortSql;
    private boolean validProject=false;

    public void sort() {
        if (createTimeSort != null || prioritySort != null
                || deadlineSort != null || totalAmountSort != null
                || realAmountSort != null) {
            sorted = true;
            sortSql = " order by ";
            List<String> sorts = new ArrayList<>();
            if (createTimeSort != null) {
                sorts.add("t.create_time " + (createTimeSort ? "desc" : "asc"));
            }
            if (prioritySort != null) {
                sorts.add("t.priority " + (prioritySort ? "desc" : "asc"));
            }
            if (deadlineSort != null) {
                sorts.add("t.deadline " + (deadlineSort ? "desc" : "asc"));
            }
            if (totalAmountSort != null) {
                sorts.add("t.total_amount " + (totalAmountSort ? "desc" : "asc"));
            }
            if (realAmountSort != null) {
                sorts.add("t.real_amount " + (realAmountSort ? "desc" : "asc"));
            }
            sortSql += String.join(",", sorts);
        }
    }
}
